<header>
  <h1><a href="../../html/index.html" class="header-title"></a></h1>
  <p class="right">
    <select class="header-select header-select-year" name="year">
      <option value="2018" selected>2018</option>
      <option value="2017">2017</option>
    </select>
    <select class="header-select header-select-month" name="month">
      <option value="1" selected>1-1</option>
      <option value="2">1-2</option>
      <option value="3">1-3</option>
      <option value="4">1-4</option>
      <option value="5">1-5</option>
      <option value="6">1-6</option>
      <option value="7">1-7</option>
      <option value="8">1-8</option>
      <option value="9">1-9</option>
      <option value="10">1-10</option>
      <option value="11">1-11</option>
      <option value="12">1-12</option>
    </select>
    <i class="header-image header-image-month"></i>
  </p>
</header>
<script>
  $(function () {
    $('.header-title').attr('href', basePath + 'html/index.html');
    $('header').prepend('<link rel="stylesheet" href="' + basePath + 'css/layout/header.min.css">');
    var headerSelect = $('.header-select');        // 头部下拉框
    var headerSelectYear = $('.header-select-year');  // 年份下拉框
    var headerSelectMonth = $('.header-select-month');  // 月份下拉框
    var headerImageMonth = $('.header-image-month');  // 月份显示图片
    /* 初始化下拉框 */
    var year = new Date().getFullYear(),
      str = '',
      select;
    for (var i = year; i >= 2017; i--) {
      select = i === year ? ' selected' : '';
      str += '<option value="' + i + '" '+ select +'>' + i + '</option>';
    }
    headerSelectYear.html(str);
    if (GetQueryString('id')) {
      headerSelectMonth.hide();
      headerImageMonth.show();
      headerSelectYear.select2({
        width: 1.6 * rem
      });
    } else {
      headerSelectMonth.show();
      headerImageMonth.hide();
      headerSelect.select2({
        width: 1.6 * rem
      });
    }
    $('.header-title').html(GetQueryString('name'));
    var date = new Date();
    headerSelectYear.val(date.getFullYear()).trigger('change');
    headerSelectMonth.val(date.getMonth() + 1).trigger('change');

    publicAjax(basePath + 'search/date', 'post', null, function (data) {
      if (data.ret === 1) {
        headerSelectYear.val(data.data.year).trigger('change');
        headerSelectMonth.val(data.data.month).trigger('change');
      }
    }, false, {async: false});

    headerImageMonth.on('click', function () {
      $('#chart').toggle();
      $('#table').toggle();
    });
  });
</script>